const websocket=require('ws')
const ws=new websocket.Server({
    port:3000
})
let count=0
ws.on('connection',(socket)=>{
    console.log('建立连接成功');
    socket.on('message',(data)=>{//接收到客户端发送过来的数据时触发
        // console.log(data.toString());
        socket.send('欢迎访问')
        setInterval(() => {
            count++
            socket.send(count)
        }, 2000);
    })
})


